<!-- FILE:templates/authorize/cloud.html -->
<!--Body content-->
<style>
.control-group.error input.parsley-validated{
    color: #b94a48 !important;
    background-color: #f2dede !important;
    border: 1px solid #EED3D7 !important;
}
</style>
<div id="content" class="clearfix">
    <div class="contentwrapper"><!--Content wrapper-->
                <!-- Build page from here: -->
    {% set app_page_title="Manage Users" %}
        <div class="row-fluid">
            <div class="offset3 span6">
                <div class="well">
                    <div class="title page-header">
                      {% if flash_message %}
                        <ul id="noticeExplanation"><li class="flash notice">{{ flash_message }}</li></ul>
                      {% endif %}

                      {% if error_flash_message %}
                        <ul id="errorExplanation"><li class="">{{ error_flash_message }}</li></ul>
                      {% endif %}

                      <h3>Authorization Info:</h3>
                    </div>
                      <form action="/authorize" method="post">
                        <table align="center" style="border: 1px solid #ddd;" class="table table-striped table-bordered">
                          <tr>
                            <td class="user_auth" align="center">Username</td>
                            <td class="user_auth" align="center">Upload / Remove App</td>
                          </tr>
                          {% for user in user_perm_list %}
                            <tr>
                              <td class="user_auth" style="text-align:center;font-weight:800;padding-top:12px" align="center">{{ user.email }}</td>
                              <input type="hidden" name="user_permission_{{ loop.counter }}" value="{{ user.email }}">
                              <td class="user_auth">
                              <input type="hidden" name="CURRENT-{{ user.email }}-upload_app"
                                {% if user.upload_app %}
                                value="True"
                                {% else %}
                                value="False"
                                {% endif %}
                              >
                               <div style="margin-left: 28px;" class="switch" data-on="success" data-off="danger">
                              <input type="checkbox" id="{{ user.email }}-upload_app" name="{{ user.email }}-upload_app"
                                {% if user.upload_app %}
                                checked="checked"
                                {% endif %}
                                value="{{ user.email }}-upload_app" />
                                </div>
                              </td>
                            </tr>
                          {% endfor %}
                        </table>
                        <div align="center" style="margin-top: 15px;">
                        <input class="btn btn-primary" name="commit" type="submit" value="Update Permissions" />
                        </div>
                      </form>
                    <br />
                        {% if is_user_cloud_admin %}
                        <div>
                            <h3 class="pull-left">Change User Password</h3><br />
                            <hr />
                        </div>
                        <div>
                            <form class="form-inline" action='/change-password' method='post' data-validate="parsley">
                                <div class="form-inline control-group">
                                    <label for="email">Email Address:</label>
                                        <div class="form-inline">
                                            <div class="controls">
                                                <input name="email" type="text" class="parsley-validated required" data-error-message="You must enter a valid user email address." data-trigger="change" data-required="true" data-type="email" placeholder="Email Address">
                                            </div>
                                        </div>
                                </div>
                                <div class="form-inline control-group">
                                    <label for="password">Password:</label>
                                        <div class="form-inline">
                                            <div class="controls">
                                            <input name="password" type="password" id="user_password" class="parsley-validated required" data-minlength="6"  placeholder="Password" />
                                            </div>
                                        </div>
                                </div>
                                <div class="form-inline control-group">
                                    <label for="password_confirm">Confirm Password:</label>
                                        <div class="form-inline">
                                            <div class="controls">
                                            <input type="password" id="change_pass" data-equalto="#user_password" name="change_pass" class="parsley-validated required" data-minlength="6" placeholder="Confirm Password"/>
                                            </div>
                                        </div>
                                </div>
                                <input class="btn btn-primary" name="submit-passwd-change" type="submit" value="Change Password">
                            </form>
                        </div>
                        {% endif %}
                </div><!--close well-->
            </div><!--close span6 -->
        </div> <!-- end row fluid -->
    </div> <!-- end content wrapper -->
</div> <!--end content-->

<script type="text/javascript">
    $(document).ready(function () {
        $('#new_user').parsley({
            successClass: 'success',
            errorClass: 'error',
            errors: {
                classHandler: function(el) {
                    return $(el).closest('.control-group');
                },
                errorsWrapper: '<span class=\"help-inline\"></span>',
                errorElem: '<span></span>'
            }
        });
    });
</script>